package com.wiseasy.smartpos.cashierdemo.util;

import android.util.Log;

public class CLog {

    public static boolean isDebug = true;//Debug mode, print Log information

    private static String className;
    private static String methodName;
    private static int lineNumber;

    private static void getMethodNames() {
        StackTraceElement[] sElements = new Throwable().getStackTrace();
        className = sElements[2].getFileName();
        methodName = sElements[2].getMethodName();
        lineNumber = sElements[2].getLineNumber();
    }

    private static String createLog(String log) {
        return "(" + className + ":" + lineNumber + ")" + "[" + methodName + "]" + log;
    }

    public static void log(String tag, String msg) {
        if (isDebug) {
            getMethodNames();
            String info = createLog(msg);
            Log.i(tag, info);
        }
    }
}
